<?php defined('SYSPATH') or die('No direct script access.');
// Event for Resque
Resque_Event::listen('afterPerform', function($job){
    $queue = $job->queue;
    $class = $job->payload['class'];
    //更改任务状态
    DB::update('queue_job')->set(array('status'=>2))
        ->where('queue_name','=',$queue)
        ->where('job_name','=',$class)
        ->execute();
});
// 任务失败
Resque_Event::listen('onFailure', function($exception,$job){
    $queue = $job->queue;
    $class = $job->payload['class'];
    //更改任务状态
    DB::update('queue_job')->set(array('status'=>3, 'exception' => $exception))
        ->where('queue_name','=',$queue)
        ->where('job_name','=',$class)
        ->execute();
});

